package theone.ui;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;

import theone.Cell;
import theone.CellState;
import theone.Game;

public class UiBoard extends UiComponent {
	
	private Image m_marble_on;
	private Image m_marble_off;
	private Image m_piece_white;
	private Image m_piece_black;
	
	private Game game;
	
	public UiBoard(Image marble_on, Image marble_off, Image piece_white, Image piece_black, Game game)
	{
		m_marble_on = marble_on;
		m_marble_off = marble_off;
		m_piece_white = marble_on;
		m_piece_black = piece_black;
		
		this.game = game;
	}
	

	@Override
	public void draw(Graphics g, int offsetX, int offsetY) {
		
		int x_diff = (getWidth() - (12*(m_marble_on.getWidth() + 4)))/2;
		int y_diff = (getHeight() - (12*(m_marble_on.getHeight() + 4)))/2;

		for (int i=0; i<12; i++)
		{
			for (int j=0; j<12; j++)
			{
				CellState st = this.game.getCells()[i][j].state;
				
				if (st != CellState.VOID) {
					g.drawImage(m_marble_on, 
							offsetX + getX() + (i*(m_marble_on.getWidth() + 4)) + x_diff, 
							offsetY + getY() + (j*(m_marble_on.getHeight() + 4)) + y_diff);
				}
				
				/*if (st == CellState.BLACK) {
					g.drawImage(m_piece_black, 
						x, y, x2, y2, srcx, srcy, srcx2, srcy2, col);
				}*/
			}
		}
	}
	

}
